﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace SoftWareLab_Project
{
    public partial class Login1 : System.Web.UI.Page
    {
        string Userdata, Passdata;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                if (Session["User"] != null)
                {
                    LB_check.Text = Session["User"].ToString();
                }
            }
        }

        protected void BT_Login_Click(object sender, EventArgs e)
        {
            login_class Log_Check = new login_class();
            string Username = TB_Username.Text;
            string Password = TB_password.Text;
            DataTable dt = Log_Check.GetData(Username, Password);

            if (dt != null && dt.Rows.Count > 0)
            {
                Userdata = dt.Rows[0]["USER_NAME"].ToString();
                Passdata = dt.Rows[0]["PASSWORD"].ToString();
                Session["User"] = Username;
                Session["pass"] = Password;
                Session["NAME"] = dt.Rows[0]["NAME"].ToString();
                Session["LASTNAME"] = dt.Rows[0]["LASTNAME"].ToString();
                Session["P_TECHNICAL"] = dt.Rows[0]["P_TECHNICAL"].ToString();
                Session["NAME_DEPARTMENT"] = dt.Rows[0]["NAME_DEPARTMENT"].ToString();
                Session["NAME_FACULTY"] = dt.Rows[0]["NAME_FACULTY"].ToString();
                Session["P_MANAGEMENT"] = dt.Rows[0]["P_MANAGEMENT"].ToString();
                Session["ID_DEPARTMENT"] = dt.Rows[0]["ID_DEPARTMENT"].ToString();

                Response.Redirect("Default.aspx");
               

            }
            else
            {

                LB_check.Visible = true;


            }
        }

        protected void BT_Cancle_Click(object sender, EventArgs e)
        {
             Response.Redirect("Login.aspx");
        }
    }
}